package ljl.codetop300;

import commons.TreeNode;

public class _230_kth_min_child {

  int k;
  int res;
  public int kthSmallest(TreeNode root, int k) {
    this.k = k;
    dfs(root);
    return res;
  }
  void dfs(TreeNode root) {
    if (root == null) return;
    dfs(root.left);
    if (--k == 0) {
      res = root.val;
      return;
    }
    dfs(root.right);
  }
}
